import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;


public class MyHttpServlet implements Servlet {

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
        //根据请求的方式，进行分别的处理
        HttpServletRequest request = (HttpServletRequest) req;

        //1.获取请求方式
        String method=request.getMethod();
        //2.判断
        if("GET".equals(method)){
            //get方式的 处理逻辑
            doGet(req,resp);
        }else if("POST".equals(method)){
            //post方式的处理逻辑
            doPost(req,resp);
        }
    }

    protected void doPost(ServletRequest req, ServletResponse resp) {
    }

    protected void doGet(ServletRequest req, ServletResponse resp) {
        //protected 表示子类可以来看到 doGet方法 表示为《子类可见》
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}

